/*
** look_player.c for zappy/serveur in /home/Smaxo/Travail/zappy-2015-2014s-renard_g/serv-src
**
** Made by maximilien addari
** Login   <addari_m@epitech.net>
**
** Started on  Mon Jun 11 11:06:14 2012 maximilien addari
** Last update Thu Jul 19 17:50:15 2012 pierrick druart
*/

#include		<string.h>
#include		<unistd.h>
#include		<stdlib.h>
#include		<stdio.h>

#include		"move_map.h"
#include		"string.h"
#include		"server.h"

static const t_dir	ptr_dir[] =
{
  {UNKNOWN, &void_funct},
  {NORD, &look_player_n},
  {EST, &look_player_e},
  {SUD, &look_player_s},
  {OUEST, &look_player_o},
};

static t_mov		init_mov(t_coord coor, t_coord map, t_mov m)
{
  m.y = coor.y;
  m.x = coor.x;
  m.sizeX = map.x;
  m.sizeY = map.y;
  return (m);
}

char			*look_player(t_game *game, t_gamer *gamer)
{
  char			*msg;
  t_mov			m;
  t_string		*string;

  string = new_string("{");
  m = init_mov(gamer->coord, game->coord, m);
  ptr_dir[gamer->direction].ptrfct(game, gamer, m, string);
  string->concat(string, "}\n");
  msg = strdup(string->str);
  string->delete(string);
  return (msg);
}
